package com.stock.demo.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.stock.demo.R;
import com.stock.demo.adapter.viewholder.StockViewHolder;
import com.stock.demo.model.TradeBean;

import java.util.ArrayList;

/**
 * Created by XuZhaoyu on 2017/7/30.
 */

public class TradeViewAdapter extends StockBaseAdapter<TradeBean> {

    public TradeViewAdapter(Context context, ArrayList<TradeBean> data) {
        super(context, data);
    }

    @Override
    public int setLayoutResId() {
        return R.layout.view_trade_list_item;
    }

    @Override
    public void onBindViewHolder(StockViewHolder holder, int position) {
        View itemView = holder.itemView;
        TradeBean bean = getItem(position);
        TextView tvName = (TextView) itemView.findViewById(R.id.tv_trade_emu_stock_name);
        tvName.setText(bean.mName);
        TextView tvMarketValue = (TextView) itemView.findViewById(R.id.tv_trade_emu_market_value);
        tvMarketValue.setText(bean.mMarketValue);
        TextView tvChangeTotal = (TextView) itemView.findViewById(R.id.tv_trade_emu_change_total);
        tvChangeTotal.setText(bean.mChangeTotal);
        TextView tvChangeTotalPercent = (TextView) itemView.findViewById(R.id.tv_trade_emu_change_percent_total);
        tvChangeTotalPercent.setText(bean.mChangePercentTotal);
        TextView tvPosition = (TextView) itemView.findViewById(R.id.tv_trade_emu_position);
        tvPosition.setText(bean.mPosition);
        TextView tvAvailable = (TextView) itemView.findViewById(R.id.tv_trade_emu_available);
        tvAvailable.setText(bean.mAvailable);
        TextView tvCost = (TextView) itemView.findViewById(R.id.tv_trade_emu_cost);
        tvCost.setText(bean.mCost);
        TextView tvPrice = (TextView) itemView.findViewById(R.id.tv_trade_emu_price);
        tvPrice.setText(bean.mPrice);
    }
}
